package cn.kgc.springboot04.Controller;

import cn.kgc.springboot04.entity.User;
import cn.kgc.springboot04.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/3/23
 * @Description:
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("list")
    public List<User>  getList(){
        return userService.list();
    }


    @RequestMapping("one")
    public User getOne(Integer id){
        return userService.getById(id);
    }

    @RequestMapping("delete")
    public String deleteOne(Integer id){
        userService.removeById(id);
        return "ok";
    }

}
